package com.kwq.designPattern.construct.flyweight;

/**
 * @author kangwanqiang
 * @date 2021/2/7
 */
public class FlyWeightClient {
    public static void main(String[] args) {
        //第一次获取，没有颜色为yellow的车，创建一个
        Car yellowCarOne = CarFactory.getCar(1);

        //第二次获取的时候map中有了颜色为黄色的车，直接拿过来用
        Car yellowCarTwo = CarFactory.getCar(1);


        //两个车是一个车
        System.out.println(yellowCarOne.hashCode() == yellowCarTwo.hashCode());
    }
}
